export const formatTime = (date = new Date()) => {
    const year = date.getFullYear()
    const month = date.getMonth() + 1
    const day = date.getDate()
    const hour = date.getHours()
    const minute = date.getMinutes()
    const second = date.getSeconds()

    return [year, month, day].map(formatNumber).join('/') + ' ' + [hour, minute, second].map(formatNumber).join(':')
}

// 判断是否是时间格式
export const isDate = (val) => {
    return Object.prototype.toString.call(val) === '[object Date]';
}

// 判断是否是普通对象
export const isPlainObject = (val) => {
    return Object.prototype.toString.call(val) === '[object object]';
}

// 获取当前时间
export const dateNow = () => {
    let date = new Date();
    const year = date.getFullYear()
    const month = date.getMonth() + 1
    const day = date.getDate()
    const hour = date.getHours()
    const minute = date.getMinutes()
    const second = date.getSeconds()

    return [year, month, day].map(formatNumber).join('-') + ' ' + [hour, minute, second].map(formatNumber).join(':')
}